<template>
  <div>
    <el-form :model="queryParam" :inline=true style="display: flex">
      <el-form-item label="编码">
        <el-input v-model="queryParam.intIds" style="width:160px"/>
      </el-form-item>
      <el-form-item label="执行ip">
        <el-input v-model="queryParam.exeIp" style="width:160px"/>
      </el-form-item>
      <el-form-item label="产品">
        <el-input v-model="queryParam.productCode" style="width:160px"/>
      </el-form-item>
      <el-form-item label="请求参数">
        <el-input v-model="queryParam.requestData" style="width:160px"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="queryPage">搜索</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="tableData" stripe style="width: 100%">
      <el-table-column label="会话" width="220">
        <template slot-scope="scope">
          <div class="typeEnter">执行ip：{{ scope.row.exeIp }}</div>
          <div class="typeEnter">序号：{{ scope.row.id }}</div>
          <div class="typeEnter">创建时间：{{ parseTime(scope.row.createTime) }}</div>
        </template>
      </el-table-column>
      <el-table-column prop="processTime" label="耗时" width="60"></el-table-column>
      <el-table-column label="信息" width="120">
        <template slot-scope="scope">
          <div class="typeEnter">产品：{{ scope.row.productCode }}</div>
          <div class="typeEnter">接口：{{ scope.row.intIds }}</div>
        </template>
      </el-table-column>
      <el-table-column label="请求与响应">
        <template slot-scope="scope">
          <div class="typeEnter">请求参数：{{ scope.row.requestData  | ellipsis }}</div>
          <div class="typeEnter">响应参数：{{ scope.row.responseData  | ellipsis }}</div>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="pageTotal>0"
      :total="pageTotal"
      :page.sync="queryParam.pageNum"
      :limit.sync="queryParam.pageSize"
      @pagination="queryPage"
    />
  </div>
</template>

<script>
import {ellipsis, parseTime} from "../../../../utils";

export default {
  data() {
    return {
      // 查询参数
      pageTotal: 0,
      queryParam: {
        intIds: '',
        exeIp: '',
        requestData: '',
        productCode: '',
        pageNum: 1,
        pageSize: 10
      },
      tableData: []
    }
  },
  mounted() {
    this.pageList()
  },
  methods: {
    parseTime,
    queryPage() {
      var _this = this
      _this.pageList()
    },
    pageList() {
      var _this = this
      this.$api.thirdLogPageList(_this.queryParam).then(res => {
        if (res.code === '00000') {
          _this.tableData = res.data.pageList
          _this.pageTotal = res.data.pageTotal
        } else {
          _this.$message(res.msg)
        }
      }).catch(e => {
        console.log('接口访问异常!')
      })
    }
  },
  filters: {
    ellipsis: (str) => ellipsis(str, 300)
  }
}
</script>
